from pydantic import BaseModel, Field
from typing import Optional
from fastapi import Query


class UserQuery(BaseModel):
    page: int = Field(1, ge=1, description="页码", alias="current")
    size: int = Field(10, ge=1, le=100, description="每页数量")
    username: Optional[str] = Field(None, description="用户名筛选")
    name: Optional[str] = Field(None, description="姓名筛选")
    email: Optional[str] = Field(None, description="邮箱筛选")
    phone: Optional[str] = Field(None, description="手机号筛选")
    department: Optional[str] = Field(None, description="部门筛选")
    status: Optional[int] = Field(None, description="状态筛选")
    create_time: Optional[str] = Field(None, description="创建时间筛选")
    update_time: Optional[str] = Field(None, description="更新时间筛选")
    keyword: Optional[str] = Field(None, description="关键词搜索（用户名/姓名/邮箱/电话）")


def user_list_query(
    page: Optional[int] = Query(None, ge=1, description="页码"),
    size: int = Query(10, ge=1, le=100, description="每页数量"),
    username: Optional[str] = Query(None, description="用户名筛选"),
    name: Optional[str] = Query(None, description="姓名筛选"),
    email: Optional[str] = Query(None, description="邮箱筛选"),
    phone: Optional[str] = Query(None, description="手机号筛选"),
    department: Optional[str] = Query(None, description="部门筛选"),
    status: Optional[int] = Query(None, description="状态筛选"),
    create_time: Optional[str] = Query(None, description="创建时间筛选"),
    update_time: Optional[str] = Query(None, description="更新时间筛选"),
    keyword: Optional[str] = Query(None, description="关键词搜索"),
) -> UserQuery:
    return UserQuery(
        page=page,
        size=size,
        username=username,
        name=name,
        email=email,
        phone=phone,
        department=department,
        status=status,
        create_time=create_time,
        update_time=update_time,
        keyword=keyword,
    )